package com.canbot.u05.utils;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
import android.content.Context;

import java.util.List;

public class ServiceUtil {

        public static boolean isServiceWork(Context mContext, String serviceName) {
                boolean isWork = false;
                ActivityManager myAM = (ActivityManager) mContext
                        .getSystemService(Context.ACTIVITY_SERVICE);
                List<RunningServiceInfo> myList = myAM.getRunningServices(40);
                if (myList.size() <= 0) {
                        return false;
                }
                for (int i = 0; i < myList.size(); i++) {
                        String mName = myList.get(i).service.getClassName().toString();

                        if (mName.equals(serviceName)) {
                                isWork = true;
                                break;
                        }
                }
                return isWork;
        }

}
